package com.nova.edc.service.system.impl;

import java.util.List;

import com.nova.frame.dao.buzz.query.Order;
import com.nova.frame.dao.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;

import com.nova.edc.dao.system.MenuDao;
import com.nova.edc.model.system.Menu;
import com.nova.edc.service.system.MenuService;

public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuDao novaMenuDao;

    @Override
    public List<Menu> findAll() {
        return novaMenuDao.findAll();
    }

    @Override
    public Menu findByMenuname(String name) {
        return novaMenuDao.query().add(Restrictions.like("MenuName", name.trim())).get();
    }

    @Override
    public List<Menu> findByParent(Integer id) {
        return novaMenuDao.query().add(Restrictions.eq("ParentID", id)).addOrder(Order.asc("Ord")).list();
    }

    @Override
    public Menu getById(Integer id) {
        return novaMenuDao.getById(id.toString());
    }
}
